package com.sulent.frame.file.vfs.example;

import org.apache.commons.vfs2.*;

import java.io.UnsupportedEncodingException;

/**
 * @ClassName VFSDemo
 * @Description: TODO
 * @Author Submerge.
 * @Since 2024/3/21 18:51
 * @Version 1.0
 */
public class VFSDemo {
    public static void main(String[] args) throws FileSystemException, UnsupportedEncodingException {

        FileSystemManager manager = VFS.getManager();

        //1.解析本地文件，
        // 格式：file:///somedir/some%25file.txt
        // 格式示例：file:///home/someuser/somedir
        System.out.println("解析本地文件：=======================================");
        FileObject fileObject1 = manager.resolveFile("hdfs://19.16.18.168:9000");
        FileName name = fileObject1.getName();
        System.out.println(name);
        FileObject[] children1 = fileObject1.getChildren();
        for (FileObject fileObject : children1) {
            System.out.println("名称：" + fileObject.getName().getBaseName() + "---" + "类型:" + fileObject.getType().getName());
//            System.out.println("大小："+fileObject.getContent().getSize());
        }

        manager.close();

    }
}